﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using BLToolkit.Data.Sql.SqlProvider;
using BLToolkit.DataAccess;
using BLToolkit.Mapping;

namespace nwrole.toolbox.sync.entity
{
    [DataContract]
    [TableName("SyncInstance")]
    public class SyncInstance
    {
        [DataMember]
        [PrimaryKey, Identity, SequenceName("nwrole")]
        public int Id { get; set; }

        [DataMember]
        [MapField("Name")]
        public string Name { get; set; }

        [DataMember]
        [MapField("LastFullSyncStart")]
        public DateTime? LastFullSyncStart { get; set; }

        [DataMember]
        [MapField("FullSyncCompleted")]
        public DateTime? FullSyncCompleted { get; set; }

        [DataMember]
        [MapField("RunFullSyncAgain")]
        public bool RunFullSyncAgain { get; set; }

        [DataMember]
        [MapField("LockedUntil")]
        public DateTime? LockedUntil { get; set; }
        
        [DataMember]
        [Association(ThisKey = "Id", OtherKey = "SyncInstanceId", CanBeNull = false)]
        public List<SyncEntity> Entities { get; set; }

        public SyncInstance()
        {
            Entities = new List<SyncEntity>();
        }

        public void AddColumn(SyncEntity entity)
        {
            Entities.Add(entity);
        }



    }
}
